<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>云创云盘 - 注册</title>
    <!--    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">-->
    <!--    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">-->

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.7" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <script>if (window.top !== window.self) {
        window.top.location = window.location;
    }</script>

    <script src="./js/axios.min.js"></script>
    <script src="https://unpkg.com/vue@2/dist/vue.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>

<body class="gray-bg">

<div id="app" class="middle-box text-center loginscreen   animated fadeInDown">
    <div>
        <div>
            <h1 class="logo-name">云</h1>
        </div>
        <h3>欢迎注册 云创云盘</h3>
        <p>创建一个云创云盘新账户</p>
        <form class="m-t" role="form" v-on:submit.prevent>
            <div class="form-group">
                <input type="text" class="form-control" v-model="userAccount" placeholder="请输入用户名" required></input>
            </div>
            <div class="form-group">
                <input type="password" class="form-control" v-model="password" placeholder="请输入密码" required>
            </div>
            <div class="form-group">
                <input type="password" class="form-control" v-model="checkPassword" placeholder="请再次输入密码"
                       required>
            </div>
            <div class="form-group">
                <div class="input-group">
                    <input type="text" class="form-control" v-model="verCode" placeholder="验证码">
                    <span class="input-group-addon no-padding"><img
                            src="/captcha" height="32"></span>
                </div>
            </div>
            <button type="submit" @click="onSubmit" class="btn btn-primary block full-width m-b">注 册</button>
            <p class="text-muted text-center"><small>已经有账户了？</small><a href="login.html">点此登录</a>
            </p>
        </form>
    </div>
</div>

<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.7"></script>
<!-- iCheck -->
<script src="js/plugins/iCheck/icheck.min.js"></script>
<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });
</script>

<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>

<script>
    new Vue({
        el: '#app',
        data() {
            return {
                userAccount: '',
                password: '',
                checkPassword: '',
                verCode: '',
            }
        },
        methods: {
            // 提交数据
            onSubmit() {
                let formList = {
                    userAccount: this.userAccount,
                    password: this.password,
                    checkPassword: this.checkPassword,
                    verCode: this.verCode,
                }
                var that = this;
                axios.post("http://localhost:80/user/register", formList)
                    .then(response => {
                        var code = response.data.code;
                        var message = response.data.message;
                        if (code === 2000) {
                            that.$message({
                                message: '注册成功，即将跳转登录页面',
                                type: 'success',
                            });
                            setTimeout(function(){
                                window.location.href = "/login.html";
                            }, 1200);
                        } else {
                            that.$message({
                                message: message,
                                type: 'error',
                            });
                        }
                    })
            }
        }
    })
</script>

</body>

</html>
